package com.yxq.mdt.app.modules.personal.model;

import com.yxq.mdt.app.base.RespBase;
import com.yxq.mdt.app.base.ibase.IBaseModel;
import com.yxq.mdt.app.constant.Constant;
import com.yxq.mdt.app.modules.personal.bean.RechargeListBean;
import com.yxq.mdt.app.modules.personal.bean.RechargePayResultBean;
import com.yxq.mdt.app.modules.personal.bean.RechargeWxPayResultBean;
import com.yxq.mdt.app.modules.withdraw.bean.WithDrawResultBean;
import com.yxq.mdt.app.net.ApiModel;
import com.yxq.mdt.app.net.BaseObserver;
import com.yxq.mdt.app.net.RetrofitFactory;

import io.reactivex.android.schedulers.AndroidSchedulers;
import io.reactivex.schedulers.Schedulers;
import retrofit2.http.Query;

/**
 * @author L
 * @time 2019-11-25
 * @describe 我的-设置$
 */
public class RechargeModel implements IBaseModel {

    public void selectPageInfoAndroid(int pageNum, int pageSize, ApiModel.CommonCallback<RechargeListBean> callback) {
        RetrofitFactory.getJavaRetrofit().create(RechargeAPI.class)
                .selectPageInfoAndroid(pageNum, pageSize)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseObserver<RechargeListBean>() {
                    @Override
                    public void onFailure(Throwable e, boolean isNetWorkError) {
                        callback.onError(e.getMessage());
                    }

                    @Override
                    public void onSuccess(RechargeListBean respBase) {
                        callback.onSuccess(respBase);
                    }
                });
    }

    public void recharge(long money, int platform, int sugarId, ApiModel.CommonCallback<RechargePayResultBean> callback) {
        RetrofitFactory.getJavaRetrofit().create(RechargeAPI.class)
                .recharge(money, platform, sugarId)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseObserver<RechargePayResultBean>() {
                    @Override
                    public void onFailure(Throwable e, boolean isNetWorkError) {
                        callback.onError(e.getMessage());
                    }

                    @Override
                    public void onSuccess(RechargePayResultBean respBase) {
                        callback.onSuccess(respBase);
                    }
                });
    }

    public void wxPay(int orderId, ApiModel.CommonCallback<RechargeWxPayResultBean> callback) {
        RetrofitFactory.getJavaFormRetrofit().create(RechargeAPI.class)
                .wxPay(orderId)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseObserver<RechargeWxPayResultBean>() {
                    @Override
                    public void onFailure(Throwable e, boolean isNetWorkError) {
                        callback.onError(e.getMessage());
                    }

                    @Override
                    public void onSuccess(RechargeWxPayResultBean respBase) {
                        callback.onSuccess(respBase);
                    }
                });
    }

    public void cashdrill(String honey_drill, int platform, int type, String mobile, String name, String bank_no, String bank_name,String contactPhone, ApiModel.CommonCallback<WithDrawResultBean> callback) {
        RetrofitFactory.getJavaRetrofit().create(RechargeAPI.class)
                .cashdrill(honey_drill, platform, type, mobile, name, bank_no, bank_name,contactPhone)
                .subscribeOn(Schedulers.io())
                .unsubscribeOn(Schedulers.io())
                .observeOn(AndroidSchedulers.mainThread())
                .subscribe(new BaseObserver<WithDrawResultBean>() {
                    @Override
                    public void onFailure(Throwable e, boolean isNetWorkError) {
                        callback.onError(e.getMessage());
                    }

                    @Override
                    public void onSuccess(WithDrawResultBean respBase) {
                        callback.onSuccess(respBase);
                    }
                });
    }

    @Override
    public void onDestroy() {

    }
}
